<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
  <link href="../../css/style.css" rel="stylesheet" type="text/css" />
  <!--axios-->
  <script type="text/javascript" src="../../js/axios.js"></script>
  <script type="text/javascript" src="../../js/jquery-3.3.1.js"></script>
  <script type="text/javascript" src="../../js/api.js"></script>
  <link rel="stylesheet" href="../../layui/css/layui.css">
  <script type="text/javascript" src="../../layui/layui.js"></script>
  <script>
    $(function (){
      view();
    })
    function getParameter(name) {
      var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i");
      var r = location.search.substr(1).match(reg);
      if (r!=null) return (r[2]); return null;
    }
    function view() {
      let orderId = getParameter("orderId");
      var url = "http://121.37.227.40:8000/"
      axios({
        url: url + 'marketing/queryOrderView',
        method: "POST",
        data: {},
        params: {
          orderId: orderId
        },
        dataType: "JSON"
      }).then(function (rel) {
        rel = rel.data
        let data = rel.resultData[0];
        let orderId = data.orderId
        let str='<div class="formtitle"><span>订购单审核</span></div>'
        str+='<ul class="forminfo">\n' +
                '    <li>\n' +
                '      <label>订单编号</label>\n' +
                '      <cite>'+ data.orderId+'</cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>客户姓名</label>\n' +
                '      <cite><a href="javascript:void(0)" title="点击查看客户详细信息" class="tablelink" onclick="cView('+data.customId+')">'+data.customName.customName+'</a></cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>联系电话</label>\n' +
                '      <cite>'+ data.customName.telephone+'</cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>订购时间</label>\n' +
                '      <cite>'+data.orderTime +'</cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>总金额</label>\n' +
                '       <cite>'+data.orderMoney +'</cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>操作人</label>\n' +
                '      <cite>'+(data.operator == null ? '':data.operator.uName)+'</cite>\n' +
                '    </li>\n' +
                '  </ul>'
        axios({
          url:url+'marketing/queryOrderDetails',
          method:"POST",
          data:{
          },
          params:{
            orderId:orderId
          },
          dataType:"JSON"
        }).then(function (rm) {
          rm = rm.data;
          str += '<table class="tablelist">\n' +
                  '      <thead>\n' +
                  '        <tr>\n' +
                  '          <th>序号</th>\n' +
                  '          <th>品牌</th>\n' +
                  '          <th>类型</th>\n' +
                  '          <th>型号</th>\n' +
                  '          <th>数量</th>\n' +
                  '          <th>单位</th>\n' +
                  '          <th>单价</th>\n' +
                  '          <th>金额</th>\n' +
                  '        </tr>\n' +
                  '      </thead>\n' +
                  '      <tbody>'
          for (var i = 0; i < rm.resultData.length; i++) {
            var data = rm.resultData[i]
            str += '<tr>\n' +
                    '          <td>' + (i + 1) + '</td>\n' +
                    '          <td>' + data.product.type.brand.brandName + '</td>\n' +
                    '          <td>' + data.product.type.typeName + '</td>\n' +
                    '          <td>' + data.product.productModel + '</td>\n' +
                    '          <td>' + data.purchaseNum + '</td>\n' +
                    '          <td>台</td>\n' +
                    '          <td>' + data.proPrice + '</td>\n' +
                    '          <td>' + data.proTotal + '</td>\n' +
                    '        </tr>'
          }
          str+=' </table>\n' +
                  '  <ul class="forminfo">\n' +
                  '    <li>\n' +
                  '      <label>审核意见</label>\n' +
                  '      <textarea class="textinput" id="opinion"></textarea>\n' +
                  '    </li>\n' +
                  '    <li>\n' +
                  '      <label>审核状态</label>\n' +
                  '      <select class="dfselect" id="estatu">\n' +
                  '          <option value="0">请选择</option>\n' +
                  '          <option value="2">通过</option>\n' +
                  '          <option value="3">不通过</option>\n' +
                  '      </select>\n' +
                  '    </li>\n' +
                  '    <li>\n' +
                  '      <label>&nbsp;</label>\n' +
                  '      <input name="" type="button" class="btn" value="审核" onclick="subExamine(\''+orderId+'\')"/>\n' +
                  '      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n' +
                  '      <input name="" type="button" class="btn" value="返回" onclick="window.location.href=\'orderExamineList.html\'"/>\n' +
                  '    </li>\n' +
                  '  </ul>'
          $("#eview").html(str)
          $('.tablelist tbody tr:odd').addClass('odd');
        })
      })
    }
    function subExamine(orderId){
      var statu=$("#estatu").val()
      var opinion=$("#opinion").val()
    var url="http://121.37.227.40:8000/"
      if (statu==0){
        layui.use('layer', function(){
          var layer = layui.layer;
          layer.msg("请选择审核状态！",{icon:5})
        });
      }else {
        axios({
          url:url+'marketing/orderAudit',
          method:"POST",
          data:{
          },
          params:{
            orderId:orderId,
            opinion:opinion,
            status:statu
          },
          dataType:"JSON"
        }).then(function (){
            location.href="orderExamineList.html"
        })
      }
    }
    function cView(customId) {
      var url="http://121.37.227.40:8000/"
      axios({
        url:url+'marketing/queryAddress',
        method:"POST",
        data:{
        },
        params:{
          customId:customId
        },
        dataType:"JSON"
      }).then(function (rel){
          rel=rel.data
        var data=rel.resultData
        goview(customId,data.city.province.pName,data.city.cName)
      })
    }
    function goview(customId,province,city){
      location.href="../customer/customerView.html?customid="+customId+"&province="+province+"&city="+city
    }
  </script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>营销管理</li>
    <li>订购单审核管理</li>
    <li>审核</li>
  </ul>
</div>
<div class="formbody" id="eview">
<!--  <div class="formtitle"><span>订购单审核</span></div>-->
<!--  <ul class="forminfo">-->
<!--    <li>-->
<!--      <label>订单编号</label>-->
<!--      <cite>DJ201711180001</cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>客户姓名</label>-->
<!--      <cite><a href="../customer/customerView.html" title="点击查看客户详细信息" class="tablelink">王金平</a></cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>联系电话</label>-->
<!--      <cite>17370899727</cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>订购时间</label>-->
<!--      <cite>2017-11-18 15:36:10</cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>总金额</label>-->
<!--       <cite>￥9,876,582</cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>操作人</label>-->
<!--      <cite>关羽</cite>-->
<!--    </li>-->
<!--  </ul>-->
<!--  <table class="tablelist">-->
<!--      <thead>-->
<!--        <tr>-->
<!--          <th>序号</th>-->
<!--          <th>品牌</th>-->
<!--          <th>类型</th>-->
<!--          <th>型号</th>-->
<!--          <th>数量</th>-->
<!--          <th>单位</th>-->
<!--          <th>单价</th>-->
<!--          <th>金额</th>-->
<!--        </tr>-->
<!--      </thead>-->
<!--      <tbody>-->
<!--        <tr>-->
<!--          <td>1</td>-->
<!--          <td>联想</td>-->
<!--          <td>笔记本电脑</td>-->
<!--          <td>T470</td>-->
<!--          <td>10</td>-->
<!--          <td>台</td>-->
<!--          <td>9998</td>-->
<!--          <td>99980</td>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <td>2</td>-->
<!--          <td>联想</td>-->
<!--          <td>笔记本电脑</td>-->
<!--          <td>X260</td>-->
<!--          <td>5</td>-->
<!--          <td>台</td>-->
<!--          <td>5500</td>-->
<!--          <td>27500</td>-->
<!--        </tr>-->
<!--      </tbody>-->
<!--  </table>-->
<!--  <ul class="forminfo">-->
<!--    <li>-->
<!--      <label>审核意见</label>-->
<!--      <textarea class="textinput" id="opinion"></textarea>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>审核状态</label>-->
<!--      <select class="dfselect">-->
<!--          <option value="0">请选择</option>-->
<!--          <option value="2">通过</option>-->
<!--          <option value="3">不通过</option>-->
<!--      </select>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>&nbsp;</label>-->
<!--      <input name="" type="button" class="btn" value="审核"/>-->
<!--      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-->
<!--      <input name="" type="button" class="btn" value="返回" onclick="window.location.href='orderExamineList.html'"/>-->
<!--    </li>-->
<!--  </ul>-->
</div>
<script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>
</html>
